﻿using System.Collections.Generic;
using System.Data;
using Think9.Models;
using Think9.Services.Base;

namespace Think9.Services.Basic
{
    public class SysParameter
    {
        /// <summary>
        /// 获得系统指标值
        /// </summary>
        public static List<valueTextEntity> GetList()
        {
            ComService comService = new ComService();
            List<valueTextEntity> list = new List<valueTextEntity>();

            var sysList = EnumHelp.GetEnumList<SysParameterEnum>();
            foreach (SysParameterEnum obj in sysList)
            {
                list.Add(new valueTextEntity { Value = "@" + obj.ToString(), Text = "{系统参数}@" + obj.ToString() + EnumHelp.GetDescriptionByEnum<SysParameterEnum>(obj), ClassID = "sys" });
            }

            DataTable dtParm = comService.GetDataTable("select * from IndexParm  ");
            foreach (DataRow dr in dtParm.Rows)
            {
                list.Add(new valueTextEntity { Value = dr["ParmId"].ToString(), Text = "{自定义参数-统计表查询使用}@" + dr["ParmName"].ToString(), ClassID = "parm" });
            }

            return list;
        }

        /// <summary>
        /// 获得系统指标值
        /// </summary>
        public static void GetList(ref DataTable dtReturn)
        {
            var list = EnumHelp.GetEnumList<SysParameterEnum>();
            foreach (SysParameterEnum obj in list)
            {
                DataRow row = dtReturn.NewRow();
                row["Value"] = "@" + obj.ToString();
                row["Text"] = "{系统参数}@" + obj.ToString() + EnumHelp.GetDescriptionByEnum<SysParameterEnum>(obj);
                dtReturn.Rows.Add(row);
            }
        }
    }
}